package com.ldy.demo2;

import org.junit.Test;

import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 描述：将springboot的 properties 转化为 yml<br>
 * 版权：Copyright (c) 2011 ~ 2017<br>
 * 公司：北京活力天汇<br>
 * 作者：刘德咏<br>
 * 版本：1.0<br>
 * 创建日期：2017/7/6<br>
 */
public class SpringTranPropertiesToYML {
    private static String INPUT_PATH = "/application.properties";
    private static String OUTPUT_PATH = "/application.yml";

    @Test
    public void tran() throws Exception {
        File inputFile = new File(this.getClass().getResource(INPUT_PATH).toURI());
        FileInputStream in = new FileInputStream(inputFile);
        InputStreamReader streamReader = new InputStreamReader(in, "utf-8");
        BufferedReader reader = new BufferedReader(streamReader);
        List<String> list = new ArrayList<String>();
        String line = reader.readLine();
        while (line != null) {
            if (line.length() > 0)
                list.add(line);
            line = reader.readLine();
        }
        File output = new File(this.getClass().getResource(OUTPUT_PATH).toURI());

        BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(output)));
    }

    public static void main(String[] args) {
        int[][] arrs = new int[][]{{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}};
        final ExecutorService serivce = Executors.newFixedThreadPool(arrs.length);
        for (final int[] arr: arrs) {
            serivce.submit(new Runnable() {
                public void run() {
                    for (int a: arr) {
                        if (a == 9) {
                            System.out.println(Thread.currentThread().getName() + "找到了9");
                            serivce.shutdownNow();
                        }
                    }
                }
            });
        }
    }

}
